<?php
        //$prideGroup = $_GET['pride_group'];
        
        $sql = "SELECT * FROM feedback_from_students ORDER BY ffs_position";
        $result = $db->Execute($sql);
        $pride_student_list = '';
        while (!$result->EOF)
        {
            $psMsg = utf8_substr($result->fields['ffs_msg'],0,250);
            
            if($result->fields['ffs_active']==1){
                $psActive = '<a href="function/feedback_from_studentsShowHideAction.php?psid='.$result->fields['ffs_id'].'"><img src="images/active.png" class="img_link showHideAction" id="'.$result->fields['ffs_id'].'" title="Click to hide"/></a>';
            }else{
                $psActive = '<a href="function/feedback_from_studentsShowHideAction.php?psid='.$result->fields['ffs_id'].'"><img src="images/unactive.png" class="img_link showHideAction" id="'.$result->fields['ffs_id'].'" title="Click to show"/></a>';
            }
            $pride_student_list .= <<<stu_hall_of_fame
                <tr>
                    <td class="align_center"style="width:80px;" ><img src="{$iniVars['Locations']['siteurl']}{$result->fields['ffs_img']}" class="prideStudentImg" style="width:80px;" /></td>
                    <td style="vertical-align:middle;">{$result->fields['ffs_name']}</td>
                    <td class="align_center" style="vertical-align:middle;"><img src="{$iniVars['Locations']['siteurl']}images/feedback_from_students/flag_{$result->fields['ffs_lang']}.jpg" /></td>
                    <td style="vertical-align:middle;">{$psMsg}</td>
                    <td class="align_center" style="vertical-align:middle;">{$psActive}<a title="Edit" href="pages/feedback_from_students-edit.php?psid={$result->fields['ffs_id']}" class="aColorBox"><img src="images/edit.png" /></a><img src="images/system-delete-alt-02.png" class="img_link deleteImg" id="{$result->fields['ffs_id']}" title="Delete"/></td>
                </tr>
stu_hall_of_fame;
            $result->MoveNext();
        }
        $result->Close();
    ?>
    <script src="js/jquery.dataTables.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery.colorbox-min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="css/datatable.css" type="text/css" media="screen" charset="utf-8" /script>
    <link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" charset="utf-8" />
    <script type="text/javascript">
        $(function() {
            $("#tabs").tabs();
        });
        
        $(document).ready(function(){
            $('.aColorBox').colorbox({width:'500',height:'90%'});
            
            $('#prideStudentList').dataTable({
                "aoColumns": [
                   { "bSortable": false, "bSearchable": false },
                   { "bSortable": true, "bSearchable": true },
                   { "bSortable": false, "bSearchable": false },
                   { "bSortable": false, "bSearchable": true },
                   { "bSortable": false, "bSearchable": false }
                ]
            });
            
            //$('.showHideAction').click(function(){
            //    var psid = $(this).attr('id');
            //    $.post('function/feedback_from_studentsShowHideAction.php','psid='+psid,function(data){
            //        if(trim(data)=='success'){
            //            location.reload();
            //        }else{
            //            alert('ไม่สามารถเปลี่ยนสถานะได้ กรุณาลองใหม่อีกครั้ง');
            //        }
            //    });
            //});
            
            $('.deleteImg').live('click',function(){
                if(confirm('Delete?')){
                        var psid = $(this).attr('id');
                        window.location = 'function/feedback_from_studentsDelete.php?psid='+psid;
                }
            });
        });
        
    </script>
    <h3 class="pageTitle">เสียงตอบกลับจากนักเรียน</h3>
    <div id="tabs" class="prideStudent">
        
        <ul>
            <li id="car_"><a href="#tabs-1" title="Add files">เสียงตอบกลับจากนักเรียน</a></li>
        </ul>
        
        <div id="tabs-1" class="prideStudentList">
            <div style="margin-bottom:25px;text-align:right;">
                <a href="pages/feedback_from_students-add.php" class="aColorBox"><img src="images/add.jpg" class="img_link"/></a>
            </div>
            <table class="display" id="prideStudentList">
                <thead>
                    <tr>
                        <th style="width:80px;">Image</th>
                        <th>Name</th>
                        <th>Language</th>
                        <th>Message</th>
                        <th>Show / Edit / Delete</th>
                    </tr>
                </thead>
                <tbody>
                <?php echo $pride_student_list; ?>
                </tbody>
            </table>
            <div class="clear"></div>
        </div>
        
    </div>